package game.model.gameEvent
{
	import game.model.gameEvent.vo.GameEventVO;
	import game.model.items.vo.ItemVO;
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.proxy.Proxy;
	import game.interfaces.IGameEvent;

	/**
	 * ...
	 * @author Thot
	 */
	
	public class GameEventProxy extends Proxy implements IProxy
	{
		//static
		static public var NAME:String = 'GameEventProxy';
		
		//private
		private var _data:Vector.<IGameEvent>;
		
		//public
		public function GameEventProxy()
		{ 
			_data = new Vector.<IGameEvent>();
			super( NAME, _data );
		}
		
		public function removeGameEvent( p_gameEventVO:IGameEvent ):void
		{
			var index:int = _data.indexOf(p_gameEventVO);
			
			if ( index != -1 )
			{
				_data.splice( index, 1 );
			}
		}
		
		public function addGameEvent( p_item:IGameEvent ):void
		{
			_data.push( p_item );
		}
		
		public function getGameEventsByTrigger( p_trigger:String ):Vector.<IGameEvent>
		{
			var i:int = _data.length;
			var gameEvent:IGameEvent = null;
			var gameEvents:Vector.<IGameEvent> = new Vector.<IGameEvent>();
			
			while ( --i > -1 )
			{
				gameEvent = _data[i];
				
				if ( gameEvent.trigger == p_trigger )
				{
					gameEvents.push(gameEvent);
				}
			}
			
			return gameEvents;
		}
	}

}